<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateContentReportsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('content_reports', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('reporter_user_id');
            $table->string('reported_content_type', 50)->comment('share, help_request, comment');
            $table->unsignedBigInteger('reported_content_id');
            $table->string('report_reason', 100)->comment('inappropriate, spam, harassment');
            $table->text('report_details')->nullable();
            $table->enum('status', ['pending', 'reviewed', 'resolved'])->default('pending');
            $table->timestamp('reviewed_at')->nullable();
            $table->timestamp('created_at')->useCurrent();
            
            // 外键约束
            $table->foreign('reporter_user_id')->references('id')->on('users')->onDelete('cascade');
            
            // 索引
            $table->index(['status']);
            $table->index(['reported_content_type']);
            $table->index(['reported_content_id']);
            $table->index(['created_at']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('content_reports');
    }
}